<div class="row mt-3">
    <div class="col-sm-12 col-md-4">
        <div class="dataTables_length">
            <label>每页
                <select name="prePageNum"  class="custom-select custom-select-sm form-control form-control-sm" style="width: 120px;">
                    <option value="10" @if($paginator->perPage() == 10) selected @endif>10 条/页</option>
                    <option value="25" @if($paginator->perPage() == 25) selected @endif>25 条/页</option>
                    <option value="50" @if($paginator->perPage() == 50) selected @endif>50 条/页</option>
                    <option value="100" @if($paginator->perPage() == 100) selected @endif>100 条/页</option>
                </select>
                条记录
            </label>
        </div>
    </div>
    <div class="col-sm-12 col-md-8">
        <div class="dataTables_paginate paging_simple_numbers">
            <ul class="pagination">
                <li class="paginate_button page-item disabled"><a href="#" class="page-link">当前页{{$paginator->count()}}条/共{{$paginator->total()}}条数据</a></li>
                @if ($paginator->hasPages())
                @if ($paginator->onFirstPage())
                    <li class="paginate_button page-item previous disabled" >
                        <a class="page-link" href="javascript:;">上一页</a>
                    </li>
                @else
                    <li class="paginate_button page-item previous ">
                        <a class="page-link" href="{{ $paginator->previousPageUrl() }}" >上一页</a>
                    </li>
                @endif

                @foreach ($elements as $element)
                    {{-- "Three Dots" Separator --}}
                    @if (is_string($element))
                        <li class="paginate_button page-item disabled" ><span>{{ $element }}</span></li>
                    @endif
                    {{-- Array Of Links --}}
                    @if (is_array($element))
                        @foreach ($element as $page => $url)
                            @if ($page == $paginator->currentPage())
                                <li class="paginate_button page-item active" >
                                    <a class="page-link" href="javascript:;">{{ $page }}<span class="sr-only">(current)</span></a>
                                </li>
                            @else
                                <li class="paginate_button page-item">
                                    <a class="page-link" href="{{ $url }}">{{ $page }}</a>
                                </li>
                            @endif
                        @endforeach
                    @endif
                @endforeach

                @if ($paginator->hasMorePages())
                    <li class="paginate_button page-item next">
                        <a class="page-link" href="{{ $paginator->nextPageUrl() }}">下一页</a>
                    </li>
                @else
                    <li class="paginate_button page-item next disabled">
                        <a class="page-link" href="javascript:;">下一页</a>
                    </li>
                @endif
              @endif
            </ul>
        </div>
    </div>
</div>
    @push('scripts')
        <script type="text/javascript">
            $("select[name='prePageNum']").on('change', function(){
                var perNum = $(this).children('option:selected').val();
                var url = window.location.href;
                if(url.indexOf("per=") >= 1){
                    var u = url.split("per=");
                }else{
                    if(url.indexOf("?") >= 1){
                        var nurl = url+"&per="+perNum;
                    }else{
                        var nurl = url+"?per="+perNum;
                    }
                }
                if(u) {
                    var e = u[1].split("&");
                    var d="";
                    if(e.length > 1){
                        for(var i=0;i<e.length-1;i++){
                            d += "&"+e[i+1];
                        }
                    }
                    var nurl = u[0] + "per=" + perNum+d;
                }
                location = nurl;
            });

            $('.btn-jump').click(function(){
                var maxPage = parseInt('{{$paginator->lastPage()}}');
                var jumpPae =  parseInt($('.page-num').val());
                jumpPae = jumpPae<=0?1:jumpPae;
                jumpPae = jumpPae>maxPage?maxPage:jumpPae;

                var url = window.location.href;
                if(url.indexOf("page=") >= 1){
                    var u = url.split("page=");
                }else{
                    if(url.indexOf("?") >= 1){
                        var nurl = url+"&page="+jumpPae;
                    }else{
                        var nurl = url+"?page="+jumpPae;
                    }
                }
                if(u) {
                    var e = u[1].split("&");
                    var d="";
                    if(e.length > 1){
                        for(var i=0;i<e.length-1;i++){
                            d += "&"+e[i+1];
                        }
                    }
                    var nurl = u[0] + "page=" + jumpPae+d;
                }
                location = nurl;
            });
        </script>
    @endpush